主题
加载图片 - LoadImage
函数简介
加载一张图片到内存,如果配置了数据库连接则优先读取数据库内图片,否则从工作目录下读取指定文件。
接口名称
LoadImageDLL调用
long LoadImage(long ola, string file_path);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| file_path | 字符串 | 图片文件路径,支持相对路径和绝对路径 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long imgPtr = ola.LoadImage("images/scene.png");csharp
using OLAPlug;
var ola = new OLAPlugServer();
long imgPtr = ola.LoadImage("images/scene.png");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
imgPtr = ola.LoadImage("images/scene.png")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long imgPtr = ola.LoadImage("images/scene.png");cpp
var ola = com("OlaPlug.OlaSoft")
var imgPtr = ola.LoadImage("images/scene.png")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
imgPtr = ola.LoadImage("images/scene.png")text
.局部变量 ola, OLAPlug
ola.创建 ()
imgPtr = ola.LoadImage(“images/scene.png“)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var imgPtr = ola.LoadImage("images/scene.png");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 imgPtr = ola.LoadImage("images/scene.png")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long imgPtr = ola.LoadImage("images/scene.png");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long imgPtr = LoadImage(instance, "images/scene.png");csharp
long instance = CreateCOLAPlugInterFace();
long imgPtr = LoadImage(instance, "images/scene.png");python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
imgPtr = LoadImage(instance, "images/scene.png")返回值
长整数型:成功返回OLAImage对象的地址,失败返回0。
注意事项
- 支持BMP、JPG、PNG格式。
- 返回的图片需调用 FreeImagePtr 释放内存。
- 建议使用绝对路径以避免路径问题。
